package cn.itcast.com.IO.zifuliu.introduction;

import java.io.*;

public class lianxi {
    public static void main(String[] args) throws IOException {
        copyFileBytes("D:\\代码\\代码\\代码\\cn\\itcast\\com\\IO\\a.txt","d:\\b.txt");
    }

    public static void copyFileBytes(String srcPath, String desPath) throws IOException {
        //创建字符流对象
        FileOutputStream fileOutputStream = new FileOutputStream(desPath);
        Writer writer = new OutputStreamWriter(fileOutputStream);
        Reader reader = new InputStreamReader(new FileInputStream(srcPath));

        //复制文件
        int len;
        char[] charBuf = new char[1024];
        while ((len =reader.read(charBuf)) != -1){
            writer.write(charBuf,0,len);
        }

        //关闭流
        writer.close();
        reader.close();
    }
}
